<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/jq-1.12.4.js"></script>
    <script>
        $(function () {
            let object = {
                apple: 0,
                banana: {
                    weight: 52,
                    price: 100
                },
                cherry: 97
            }
            let object1 = {
                banana: {
                    price: 200
                },
                durian: 100
            }

            //深度合并 改变精确到对象里面 不加true 改成banana: { price: 200 }
            let target = $.extend(true, object, object1)
            console.log(target);

            let app = $("#app")
            //是否是普通的对象
            //console.log($.isPlainObject(123))
            //是否是空对象
            //console.log($.isEmptyObject({}))
            // typeof JSON !== 'undefined'
            let printObj = false ? JSON.stringify : function (obj) {
                let arr = []
                $.each(obj, function (key, value) {
                    console.log(key, value)
                    let next = key + ":"
                    next += $.isPlainObject(value) ? printObj(value) : value
                    arr.push(next)
                })
                return "{" + arr.join(",") + "}"
            }

            let str = printObj(target)
            console.log(str)
         })
    </script>
</head>

<body>
    <div id="app"></div>
</body>

</html>